// https://vuex.vuejs.org/en/mutations.html

//集中处理状态
export default {
    /**
     * 注册用户信息
     * @param state
     * @param user
     */
    registerUserData(state, user) {
        state.user.username = user.name;
        state.user.avatar = user.avatar;
        state.user.signature = user.signature;
    },
    clearStateData(state) {
        state.user.username = "";
        state.user.avatar = "";
        state.user.signature = "";
    },
    showLogin(state) {
        state.sys.showLogin = true;
    },
    hideLogin(state) {
        state.sys.showLogin = false;
    },
    resetTabMenu(state) {
        state.sys.checkMenuNav = 0;
    },
    resetBlogData(state) {
        state.blog.blogType = "";
        state.blog.blogTag = "";
    },
    toggleBlogTypeSelected(state) {
        //当点击时 blogType 为true选中状态,则清空store中的blogType的值,以及选中的状态值
        if (state.blog.isTypeSelected) {
            state.blog.blogType = "";
            state.sys.checkBlogType = "";
        }
        state.blog.isTypeSelected = !state.blog.isTypeSelected;

    },
    toggleBlogTagSelected(state) {
        //当点击时 blogType 为true选中状态,则清空store中的blogType的值,以及选中的状态值
        if (state.blog.isTagSelected) {
            state.blog.blogTag = "";
            state.sys.checkBlogTag = "";
        }
        state.blog.isTagSelected = !state.blog.isTagSelected;
    }
}
